﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZX.Web.UI.Controls;
using ZX.CRM.Library;
using ZX.DBModule;
using ZX.SYS.Library;
using ZX.CRM.Bussiness;
using ZX.Common;
using ZX.BLL;

namespace ZX.WebApp.Crm.Sale
{
    public partial class AddOrderSale : BasePage
    {
        BTCrmCustomer bll = new BTCrmCustomer();
        BTCrmCrustomerOrder order = new BTCrmCrustomerOrder();
        BDatPhraseDetail bllDetail = new BDatPhraseDetail();
        string strListProduct = "", strUnitId = "", strOrder = "", strState = "",
            strPayType = "", strPayAccount = "", strPayId = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            #region-----------jsonData-----------
            IList<V_CrmProduct> ListProduct = order.GetAllCrmCustomerProduct("");
            if (ListProduct != null && ListProduct.Count > 0)
            {
                IList<BaseEntity> _ListProduct = new List<BaseEntity>();
                foreach (var _e in ListProduct)
                {
                    _ListProduct.Add(_e);
                }
                strListProduct = _ListProduct.ToJSON().Replace("\n", "").Replace("\r", "").Replace("@@", "");
            }
            IList<DatPhraseDetail> ListUnitId = bllDetail.GetDatPhraseDetailByClassValue("UnitId");
            if (ListUnitId != null && ListUnitId.Count > 0)
            {
                IList<BaseEntity> _ListUnitId = new List<BaseEntity>();
                foreach (var _e in ListUnitId)
                {
                    _ListUnitId.Add(_e);
                }
                strUnitId = _ListUnitId.ToJSON().Replace("\n", "").Replace("\r", "").Replace("@@", "");
            }
            IList<V_CrmCustomerInfoDeliver> ListOrder = order.GetAllCrmCustomerInfoOrderByCustomerId(new Guid(Id));
            if (ListOrder != null && ListOrder.Count > 0)
            {
                IList<BaseEntity> _ListOrder = new List<BaseEntity>();
                foreach (var _e in ListOrder)
                {
                    _ListOrder.Add(_e);
                }
                strOrder = _ListOrder.ToJSON().Replace("\n", "").Replace("\r", "").Replace("@@", "");
            }
            //订单状态
            IList<DatPhraseDetail> ListStateId = bllDetail.GetDatPhraseDetailByClassValue("OrderStateID");
            if (ListStateId != null && ListStateId.Count > 0)
            {
                IList<BaseEntity> _ListStateId = new List<BaseEntity>();
                foreach (var _e in ListStateId)
                {
                    _ListStateId.Add(_e);
                }
                strState = _ListStateId.ToJSON().Replace("\n", "").Replace("\r", "").Replace("@@", "");
            }
            //PayType
            IList<DatPhraseDetail> listPayType = bllDetail.GetDatPhraseDetailByClassValue("PaymentID");
            if (listPayType != null && listPayType.Count > 0)
            {
                IList<BaseEntity> _ListPayType = new List<BaseEntity>();
                foreach (var _e in listPayType)
                {
                    _ListPayType.Add(_e);
                }
                strPayType = _ListPayType.ToJSON().Replace("\n", "").Replace("\r", "").Replace("@@", "");
            }
            //PayAccount
            IList<DatPhraseDetail> listPayAccount = bllDetail.GetDatPhraseDetailByClassValue("BankAccount");
            if (listPayAccount != null && listPayAccount.Count > 0)
            {
                IList<BaseEntity> _listPayAccount = new List<BaseEntity>();
                foreach (var _e in listPayAccount)
                {
                    _listPayAccount.Add(_e);
                }
                strPayAccount = _listPayAccount.ToJSON().Replace("\n", "").Replace("\r", "").Replace("@@", "");
            }
            //PayId
            IList<CrmPay> listPayId = order.GetAllCrmPayIdByCustomerId(new Guid(Id));
            if (listPayId != null && listPayId.Count > 0)
            {
                IList<BaseEntity> _listPayId = new List<BaseEntity>();
                foreach (var _e in listPayId)
                {
                    _listPayId.Add(_e);
                }
                strPayId = _listPayId.ToJSON().Replace("\n", "").Replace("\r", "").Replace("@@", "");
            }
            #endregion
        }

        #region ---------------
        /// <summary>
        /// 标题
        /// </summary>
        public string PageTitle
        { get { return this.GetStringFromQueryString("title", ""); } }
        /// <summary>
        /// ID
        /// </summary>
        public string Id
        { get { return this.GetStringFromQueryString("id", ""); } }
        /// <summary>
        /// 产品列表
        /// </summary>
        public string ListCrmProduct
        { get { return strListProduct; } }
        /// <summary>
        /// 计量单位
        /// </summary>
        public string ListUnitId
        { get { return strUnitId; } }
        /// <summary>
        /// 订单列表
        /// </summary>
        public string ListOrder
        { get { return strOrder; } }
        /// <summary>
        /// 订单状态
        /// </summary>
        public string ListState
        { get { return strState; } }

        public string PayType
        { get { return strPayType; } }
        public string PayAccount
        { get { return strPayAccount; } }
        public string PayId
        { get { return strPayId; } }
        #endregion
    }
}